<?php
defined('BASEPATH') OR exit('No direct script access allowed');
 
class Member extends CI_Controller {

	 var $dbmain;

     function __construct()
	 {
		    parent::__construct();
            include_once "func.php";
            $this->dbmain = $db;
	 }

	public function getlist(){

		$pageno = 1;
		if(isset($_GET['page_no'])){
			$pageno = $_GET['page_no'];
		}
		$pagesize = 10 ;
  	 	$rs_number = ($pageno - 1) * $pagesize ;


		$sql = "select a.* from member a where a.nickname!='' order by a.id desc limit $rs_number,$pagesize";
		$memberList = $this->dbmain->get_results($sql);
		$count = count($memberList);
 
        $data = array(
			'member_list' => $memberList,
			'count' => $count,
			'page_no' => $pageno
		);
  
		ajax_return($data);
	}

	public function profile(){

		if(!isset($_GET["id"])){
			exit;
		}

	 	$mid = $_GET["id"];
	 	$sql = "select a.* from member a where a.id='$mid'";
 	 	$member = $this->dbmain->get_row($sql);

 
        $data = array(
			'member' => $member,
			'relationship' => '0'
		);
  
		ajax_return($data);
	}



	public function index()
	{  

		//获取wx_openid
		$openid = '';

		//如果有wx_openid 直接获取member表的信息 
		$member = null;
        $data = array(
 			'stype' => 'all'
		);

		//如果没有 跳转到注册页面
		if(!$member){
			 $this->load->view('login',$data);
		}else{
			 $this->load->view('profile',$data);
		}
 
 	}

}
